t = int(input())
while t:
s = input()
if s != s[::-1]:
print(s)
else:
ans = ""
for i in sorted(s):
ans += i
if ans == s:
print(-1)
else:
print(ans)
t-=1
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
while (n--)
{
string s;
cin >> s;
sort(s.begin(), s.end());
// cout << s << endl;
if (s[0] == s[s.size() - 1])
{
cout << -1 << endl;
continue;
}
cout << s << endl;
}
return 0;
}
1735B - Tea with Tangerines | 1735C - Phase Shift |
1321C - Remove Adjacent | 281B - Nearest Fraction |
1043A - Elections | 1598C - Delete Two Elements |
1400C - Binary String Reconstruction | 1734D - Slime Escape |
1499A - Domino on Windowsill | 991A - If at first you don't succeed |
1196C - Robot Breakout | 373A - Collecting Beats is Fun |
965A - Paper Airplanes | 863E - Turn Off The TV |
630E - A rectangle | 1104A - Splitting into digits |
19C - Deletion of Repeats | 1550B - Maximum Cost Deletion |
1693A - Directional Increase | 735D - Taxes |
989A - A Blend of Springtime | 339C - Xenia and Weights |
608A - Saitama Destroys Hotel | 1342C - Yet Another Counting Problem |
548A - Mike and Fax | 109A - Lucky Sum of Digits |
864C - Bus | 626B - Cards |
1221A - 2048 Game | 1374D - Zero Remainder Array |